#ifndef SHAREDUTIL_HPP
#define SHAREDUTIL_HPP

#include <QLineF>
#include <QPolygonF>

namespace SharedUtil {
  bool isPointOnLine( const QPointF& pt, const QLineF& line );

  bool lineInterCircle( const QLineF& line, const QPointF& center, float radius, QPolygonF& interPts );

  QRectF getBoundingRect( const QPointF& p1, const QPointF& p2 );

  QList<QPolygonF> getSelfIntersectPoints( const QPolygonF& polyline );

  QPolygonF getIntersectPoints( const QPolygonF& pline1, const QPolygonF& pline2,
                                int intersectType=QLineF::BoundedIntersection );

  void getIntersectPoints( const QPolygonF& pline1, const QPolygonF& pline2,
                           QList<QPolygonF>& pts1, QList<QPolygonF>& pts2 );

  void sortIntersectPoints( const QPolygonF& polyline, QList<QPolygonF>& intersectPoints );

  //QList<QPolygonF> clippingByCircle( float radius, const QPolygonF& polyline );

  QList<QPolygonF> clippingByCircle( const QPointF& center, float radius, const QPolygonF& polyline );
};

/*
Definition 1 (Polyline curve).
*/

/*
Definition 2 (Local self-intersection point (LSIP))
  SIP is the intersection point between the two neighboring segments.
*/

/*
Definition 3 (Extended intersection).
*/

/*
Definition 4 (False intersection point (FIP), True intersection point (TIP)).

Positive false intersection point (PFIP)
Negative false intersection point (NFIP)
*/

/*
Definition 5 (Local overlapping).
*/

/*
Definition 6 (General closest point pair (GCPP)).
*/

/*
Definition 7 (Untrimmed offset curves).
*/

/*
Untrimmed offset curves: Get the intersection points of extended intersecting between the offset curves Si and Si+1.
*/

/*
Clipping algorithm:
  Step1. Dual clipping.
  Step2. GCPP clipping.
*/

#endif